import 'package:base/base/theme.dart';
import 'package:base/base_lib.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../res/images.dart';
import '../res/lang.dart';
import 'inbox_logic.dart';

class InBoxPage extends StatelessWidget {
  final logic = Get.put<InBoxLogic>(InBoxLogic());

  InBoxPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: logic.titles.length,
        child: Scaffold(
          appBar: PreferredSize(
              preferredSize: Size.fromHeight(80.h),
              child: ToolBar.noBack(InBoxStrRes.inbox,
                  bottom: TabBar(
                      tabs: logic.titles
                          .map((e) => Tab(
                                  child: Text(
                                e,
                                style: KTheme.appBarSubTitleStyle,
                              )))
                          .toList()))),
          body: TabBarView(
            children: logic.titles.map((e) => getBody(0)).toList(),
          ),
        ));
  }

  ///数据成功的视图

  Widget get _successWidget {
    return Text("ok");
  }

  Widget getBody(int type) {
    return EmptyWidget(
      state: LoadState.State_Empty,
      successWidget: _successWidget,
      emptyWidget: _emptyView,
    );
  }

  ///数据为空的视图
  Widget get _emptyView {
    return SizedBox(
      width: double.infinity,
      height: double.infinity,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          SizedBox(
            height: 100.h,
          ),
          InboxImageRes.ill_empty_state_messages.assetImage(),
          Padding(
            padding: const EdgeInsets.only(top: 10),
            child: Text(
              InBoxStrRes.no_messages_yet,
              style: KTheme.emptyViewTextStyle,
            ),
          )
        ],
      ),
    );
  }
}
